@import 'settings';

@mixin vf-p-side-navigation-expandable {
  .p-side-navigation__item,
  .p-side-navigation__item--title {
    // position relative for the absolutely positioned `.p-side-navigation__expand` button
    position: relative;
  }
  .p-side-navigation__link.is-expandable,
  .p-side-navigation__text.is-expandable {
    // extra padding to accomodate for `.p-side-navigation__expand` button
    padding-right: 3rem;
  }

  .p-side-navigation__expand {
    @include vf-button-base;
    background: none;
    background-color: inherit;
    border: 0;
    border-radius: 0;
    font-size: inherit;
    line-height: inherit;
    margin: 0;
    padding-bottom: $spv--x-small;
    padding-top: $spv--x-small;
    position: absolute;
    right: 0;
    top: 0;

    &::before {
      @extend %icon;
      @include vf-icon-chevron-themed;
      content: '';
      transform: rotate(-90deg);
      transition: transform 100ms;
    }

    &:hover {
      background: $colors--theme--background-hover;
      color: $colors--theme--text-default;
    }
  }

  .p-side-navigation__expand[aria-expanded='true'] {
    background-color: inherit;

    &::before {
      transform: rotate(0deg);
    }

    &:hover {
      background: $colors--theme--background-hover;
      color: $colors--theme--text-default;
    }
  }

  // transition
  .p-side-navigation__list {
    @include vf-animation(#{transform, opacity}, fast);
  }
  .p-side-navigation__expand[aria-expanded='false'] + .p-side-navigation__list {
    height: 0;
    opacity: 0;
    overflow: hidden;
    transform: translate3d(0, -0.5rem, 0);
    // disable transition on close
    transition-duration: 0s;
    visibility: hidden;
  }

  .p-side-navigation__expand[aria-expanded='true'] + .p-side-navigation__list {
    height: auto;
    opacity: 1;
    transform: translate3d(0, 0, 0);
    visibility: visible;
  }
}
